package net.sxnic.item.mdata;

import net.sxinfo.core.dao.Page;
import net.sxinfo.core.spring25.Dao;
import net.sxinfo.core.spring25.DefaultManager;
import net.sxnic.item.mdata.dao.MdataDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("mdataManager")
public class DefaultMdataManager extends
		DefaultManager<Mdata, MdataDao, String> implements MdataManager {

	@Autowired
	private MdataDao mdataDao;

	@Override
	protected Dao<Mdata, String> getEntityDao() {
		return mdataDao;
	}

	@Override
	public Page findApprovePage(int page, int pageSize, String appYear,
			String catalog1, String catalog2, String userName) {
		return null;
	}

	@Override
	public Page findVerifyPage(int page, int pageSize, String appYear,
			String catalog1, String catalog2, String taskAssginee) {
		return null;
	}

	@Override
	public int deleteMdataById(String id) {		
		 mdataDao.deleteSubTables(id);
		 mdataDao.deleteById(id);
		 return 0;
	}

	@Override
	public Page getStatDataByName(int pageNo, int pageSize, String zxName) {
		// TODO Auto-generated method stub
		return mdataDao.getStatDataByName(pageNo, pageSize, zxName);
	}
	
	/**
	 * 获取当前年的申报项目实体的ID
	 * @param catalog1 大类别
	 * @param approver 申报人
	 * @param appYear 年份
	 * @return 项目实体的ID
	 */
	public String getCurrentItem(String catalog1,String approver,String appYear)
	{
		String temp = "";
		Mdata mdata = mdataDao.getCurrentItem(catalog1, approver, appYear);
		if(mdata!=null)
		{
			temp = mdata.getId();
		}
		return  temp;
	}

}
